package com.adtec.base.cloud.baseservice.rbac.system.service;

import com.adtec.base.cloud.baseservice.rbac.system.utils.ExecuteSQLUtil;
import com.adtec.base.cloud.baseservice.rbac.system.utils.Screw;
import com.adtec.base.cloud.security.jwt.utils.GetUserId;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Connection;

@Service
@Slf4j
public class SysResetService {

    @Autowired
    ExecuteSQLUtil executeSQLUtil;
    @Resource
    private GetUserId getUserId;

    @Autowired
    Screw screw;

    public boolean reset() {
        String usernameFromHeader = getUserId.getUsernameFromHeader();
        if ("admin".equalsIgnoreCase(usernameFromHeader)) {

        Connection connection = executeSQLUtil.executeSql("./doc/sql/reset/resetsys.sql");

//            Connection connection = executeSQLUtil.executeSql("static/resetsys.sql");
            return true;
        } else {
            return false;
        }
    }

    public void getScrewFile() {
        screw.getScrewFile();
    }
}
